package com.ericcson.innerportalapp;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class OfficeListArrayAdapter extends ArrayAdapter<Office> {
	
	private int resource;

	public OfficeListArrayAdapter(Context context, int resource,
			 List<Office> objects) {
		super(context, resource, objects);
		this.resource = resource;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		Office office = getItem(position);
		LayoutInflater layoutInflator = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View listItemView = layoutInflator.inflate(resource, null);
		
		TextView textView = (TextView) listItemView.findViewById(R.id.office_list_item);
		
		textView.setText(office.getName());
		textView.setTextColor(getContext().getResources().getColor(android.R.color.holo_blue_dark));
		
		return listItemView;
	}

}
